//
//  HDAppDelegate.h
//  healthyexpert
//
//  Created by Liu Penny on 15-1-14.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <TencentOpenAPI/TencentOAuth.h>
#import <TencentOpenAPI/TencentApiInterface.h>
#import "sdkCall.h"
#import "WXApi.h"
#import "SvUDIDTools.h"
#import <sqlite3.h>
#import "AFNetworking.h"
#import "AFNetworkActivityIndicatorManager.h"
#import "AFHTTPRequestOperation.h"
#import "MTA.h"
#import "MTAConfig.h"
#import <CoreLocation/CoreLocation.h>
#import "JKHttpClient.h"
#import "JSONKit.h"
#import "XCommon.h"
#import "KXH_Color.h"
#import "MBProgressHUD.h"
#import <SystemConfiguration/SystemConfiguration.h>
#import <CommonCrypto/CommonDigest.h>

#import "FMDatabaseQueue.h"

#import "GexinSdk.h"

//键盘对象
#import "LMBangEmojiView.h"

//返回APP代理对象
#define ApplicationDelegate ((HDAppDelegate *)[UIApplication sharedApplication].delegate)

//判断iPhone和iPad
#define IS_IPHONE (!IS_IPAD)
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone)
//判断设备版本
#define IS_IOS6_LAGACY floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1
#define IS_IOS7 floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1
#define IS_IOS5_LAGACY floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_5_1
#define IS_IOS6_AFTER floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_5_1
#define ScreenHeight [[UIScreen mainScreen] bounds].size.height
#define ScreenWidth [[UIScreen mainScreen] bounds].size.width
#define IS_IPHONE4 [[UIScreen mainScreen] bounds].size.height == 480
#define IS_IPHONE5 [[UIScreen mainScreen] bounds].size.height == 568
#define IS_IPHONE6 [[UIScreen mainScreen] bounds].size.height == 667
#define IS_IPHONE6p [[UIScreen mainScreen] bounds].size.height == 736
//appid secret
#define WX_APP_ID @"wxe544df8841a35c03"
#define WX_APP_SECRECT  @"da0f0d44b5c2fe405e6dba8914994064"
#define QQ_APP_ID @"1104524285"
//登陆url
#define URL_BASE @"http://mu.kangxihui.com/"
#define METHOD_LOGIN @"user/member/authlogin"
#define URL_PHONE_NUMBER @"user/member/checkphone"
#define URL_PHONE_REGSITER @"user/member/phonereg"
#define URL_FIND_PWD @"user/member/getpasswordcode"
#define URL_NEW_PWD @"user/member/changepassword"
#define URL_LOCAL_LOGIN @"user/member/login"
//上报url
#define URL_BERICHTEN @"dataupload/android_traffic_analysis.php"
//更新url
#define URL_UPDATE_USERINFO @"user/profile/detail_v2"
//当前版本号
#define APP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
//包名
#define APPVERSIONNAM @"com.kangxihui.mall"
//keychian
#define KEY_CHAIN_UDID [SvUDIDTools UDID]
//数据库名称
#define kDatabaseName @"Jkdrdatabase3.sqlite3"
#define QQ_TABLE_NAME @"qq"
#define WX_TABLE_NAME @"weixin"
//MTA
#define MTA_APPKEY @"IE9UF45T5NYU"
//个推
#define GT_APP_ID     @"8XbBkXjT3e7DrdgQYgNYd3"
#define GT_APP_KEY    @"TbBz4BQpdd7Die1gII0UO"
#define GT_APP_SECRET @"KM8D6WggmV9YYFZ7moLX0A"
//iTunes ID
#define ITUNEA_ID @"960909368"

@class HDLoginoutViewController;
typedef enum {
    SdkStatusStoped,
    SdkStatusStarting,
    SdkStatusStarted
} SdkStatus;

@interface HDAppDelegate : UIResponder <UIApplicationDelegate,WXApiDelegate,CLLocationManagerDelegate,GexinSdkDelegate>{
@private
    UINavigationController *_naviController;
    NSString *_deviceToken;
}


@property (strong, nonatomic) UIWindow *window;

@property (nonatomic, retain) FMDatabaseQueue * fmdbQueue;

//@property (nonatomic,retain) HDLoginoutViewController * viewController;

//表情键盘
@property (nonatomic, retain) NSArray *emojiStrings;//表情字符串
@property (nonatomic, retain) LMBangEmojiView *emojiKeyboard;//表情键盘

- (void) hideEmojiKeyboard;//隐藏表情键盘
- (void) showEmojiKeyboard;//显示表情键盘
//SN整理的Url
@property (nonatomic, retain) SNUniteUrl * uniteUrl;

@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
//@property sqlite3 * database;

@property (assign,nonatomic) BOOL state;
@property (strong,nonatomic) UIStoryboard *storyBoard;
@property (strong,nonatomic) CLLocationManager * location;
@property (nonatomic,retain) HDLoginoutViewController* loginViewController;

@property (strong,nonatomic) NSMutableArray * pushInfoArray;
@property (strong,nonatomic) NSDictionary * pushInfo;

//个推属性及方法
@property (strong, nonatomic) GexinSdk *gexinPusher;
@property (retain, nonatomic) NSString *gt_appKey;
@property (retain, nonatomic) NSString *gt_appSecret;
@property (retain, nonatomic) NSString *gt_appID;
@property (retain, nonatomic) NSString *clientId;
@property (assign, nonatomic) SdkStatus sdkStatus;
@property (assign, nonatomic) int lastPayloadIndex;
@property (retain, nonatomic) NSString *payloadId;
@property (strong,nonatomic) NSString * noticId;


- (void)setDeviceToken:(NSString *)aToken;
- (BOOL)setTags:(NSArray *)aTag error:(NSError **)error;
- (NSString *)sendMessage:(NSData *)body error:(NSError **)error;


- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;

-(NSString*)dataFilePath;
-(NSString*)MD5:(NSString*)str;
-(void)berichten:(NSString*)page;
-(BOOL)analytic:(NSDictionary*)request;
-(NSDictionary*)readSqlite:(NSString*)tableName;

-(void)updateUserInfo;

- (void)startSdkWith:(NSString *)appID appKey:(NSString *)appKey appSecret:(NSString *)appSecret;
- (void)registerRemoteNotification;
- (void)uploadUidAndCid;
@end
